/*
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */

/*
 *
 *
 *
 *
 *
 * Written by Doug Lea with assistance from members of JCP JSR-166
 * Expert Group and released to the public domain, as explained at
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

package java.util.concurrent;

/**
 * ThreadPoolExecutor无法执行的任务的处理程序。
 * 实现类
 * {@link ThreadPoolExecutor.AbortPolicy }
 * {@link ThreadPoolExecutor.CallerRunsPolicy }
 * {@link ThreadPoolExecutor.DiscardOldestPolicy  }
 * {@link ThreadPoolExecutor.DiscardPolicy  }
 */
public interface RejectedExecutionHandler {

    /**
     * ThreadPoolExecutor当execute无法接受任务时可能调用的方法。
     * 当没有更多线程或队列插槽可用时，可能会发生这种情况，因为它们的边界将被超出，或者在执行程序关闭时。
     *
     * @param r        请求执行的可运行任务
     * @param executor 执行者尝试执行此任务
     * @throws RejectedExecutionException 如果没有补救措施
     */
    void rejectedExecution(Runnable r, ThreadPoolExecutor executor);
}
